package com.vf.cloud.paas.common.service;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

public interface IRedis {
	
	
	
	public Set<String> getByPrefix(String prefix);
	

	public Set<String> getByUuidPrefix(String uuid);
	public Set<String> getByUuidPrefix(String type,String uuid) ;
	
	public Set<String> getByForRunCmd(String uuid);
	
	
	/**
	 * 数据缓存至redis
	 *
	 * @param key
	 * @param value
	 * @return
	 */
	public <K, V> void add(K key, V value);

	/**
	 * 数据缓存至redis并设置过期时间
	 *
	 * @param key
	 * @param value
	 * @return
	 */
	public <K, V> void add(K key, V value, long timeout, TimeUnit unit);

	/**
	 * 写入 hash-set,已经是key-value的键值，不能再写入为hash-set
	 *
	 * @param key    must not be {@literal null}.
	 * @param subKey must not be {@literal null}.
	 * @param value  写入的值
	 */
	public <K, SK, V> void addHashCache(K key, SK subKey, V value);

	/**
	 * 写入 hash-set,并设置过期时间
	 *
	 * @param key    must not be {@literal null}.
	 * @param subKey must not be {@literal null}.
	 * @param value  写入的值
	 */
	public <K, SK, V> void addHashCache(K key, SK subKey, V value, long timeout, TimeUnit unit);

	/**
	 * 获取 hash-setvalue
	 *
	 * @param key    must not be {@literal null}.
	 * @param subKey must not be {@literal null}.
	 */
	public <K, SK> Object getHashCache(K key, SK subKey);

	/**
	 * 从redis中获取缓存数据，转成对象
	 *
	 * @param key   must not be {@literal null}.
	 * @param clazz 对象类型
	 * @return
	 */
	public <K, V> V getObject(K key, Class<V> clazz);

	/**
	 * 从redis中获取缓存数据，转成list
	 *
	 * @param key   must not be {@literal null}.
	 * @param clazz 对象类型
	 * @return
	 */
	public <K, V> List<V> getList(K key, Class<V> clazz);

	/**
	 * 功能描述：Get the value of {@code key}.
	 *
	 * @param key must not be {@literal null}.
	 * @return java.lang.String
	 * @date 2021/9/19
	 **/
	public <K> String get(K key);

	/**
	 * 删除key
	 */
	public void delete(String key);

	/**
	 * 批量删除key
	 */
	public void delete(Collection<String> keys);

	/**
	 * 序列化key
	 */
	public byte[] dump(String key);

	/**
	 * 是否存在key
	 */
	public Boolean hasKey(String key);

	/**
	 * 设置过期时间
	 */
	public Boolean expire(String key, long timeout, TimeUnit unit);

	/**
	 * 设置过期时间
	 */
	public Boolean expireAt(String key, Date date);

	/**
	 * 移除 key 的过期时间，key 将持久保持
	 */
	public Boolean persist(String key);

	/**
	 * 返回 key 的剩余的过期时间
	 */
	public Long getExpire(String key, TimeUnit unit);

	/**
	 * 返回 key 的剩余的过期时间
	 */
	public Long getExpire(String key);

}
